﻿/*
 * Author: Brian Brewder
 * Website: http://redwerb.com
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using Microsoft.VisualStudio.DebuggerVisualizers;
using System.Drawing;
using System.IO;
using System.Xml;

[assembly: DebuggerVisualizer(typeof(Redwerb.Visualizers.TextVisualizer.TextVisualizer), typeof(VisualizerObjectSource), Target = typeof(string), Description = "Text File Visualizer")]

namespace Redwerb.Visualizers.TextVisualizer
{

    public class TextVisualizer
        : DialogDebuggerVisualizer
    {

        protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
        {
            var str = objectProvider.GetObject() as string;
            if (str == null) return;
            if (str.Length == 0) return;
            
            var tmpPath = Path.GetTempFileName();
            File.WriteAllText(tmpPath, str);

            var notepadPath = VizCfg.Value("Text", "Path", "notepad");
            var p = Process.Start(notepadPath, tmpPath);
        }

    }
}
